<%@ include file="/taglibs.jsp"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<fmt:message key="date.format" var="df" scope="page"/>

<head>
	<title><fmt:message key="report.form.title"/></title>
</head>

<s:set name="reports" value="reports" scope="request"/>
<s:form name="searchByPeriodForm" action="searchByPeriod" method="post">

<s:select key="reportByDepartment.form.department" name="departmentId" list="departments" listKey="id" listValue="name" ></s:select>

<table class="table">
<tr>
	<td width="120px">
        <s:property value="getText('report.fromdate')"/>
    </td>
    <td width="220px">
        <s:textfield id="fromDate" readonly="true" name="fromDate" size="11" theme="simple" required="true"/>
    </td>
	<td width="100px">
        <s:property value="getText('report.todate')"/>
    </td>
    <td>
        <s:textfield id="toDate" readonly="true" name="toDate" size="11" theme="simple" required="true"/>
    </td>     
</tr>   
<tr>
	<td colspan="4">
	
	<button type="submit" onclick="this.blur()" class="button"
					name="reportOnTime">
					<fmt:message key="button.execute.title"></fmt:message>
					<img src="${ctx}/images/report.png" align="left" height="20"
						width="20">
				</button>
	
	</td>
	
</tr>
</table>
</s:form>
<p></p>
<s:url action="exportReport" var="exportReportURL">
	<s:param name="reportType" value="3"></s:param>
</s:url>
<div align="right">
<c:if test="${fn:length(reports) gt 0}">
	<s:url action="exportDocFile!exportSynthesisReport.html"
		var="exportVoucherURL"></s:url>
	<s:a href="%{exportVoucherURL}" >
		<img src="${ctx}/images/export_word.png">
	</s:a>
</c:if>
</div>
<br>

<table class="table">
<tr>
	<td width="150px"><strong><s:property value="getText('report.form.lastmonth')"/></strong></td>
	<td width="220px">
        <strong><s:property value="fileRemainLastMonth"/></strong> <s:property value="getText('report.form.file')"/>
    </td>
	<td width="150px"><strong><s:property value="getText('report.form.thismonth')"/></strong></td>
	<td>
        <strong><s:property value="fileReceivedThisMonth"/></strong> <s:property value="getText('report.form.file')"/>
    </td>
</tr>
</table>

<display:table name="reports" class="table"  id="reportList" export="false" partialList="false">
	<display:setProperty name="paging.banner.all_items_found" value="" />
	<display:column style="width:350px"  media="html" titleKey="report.form.table.header.category" >
		<c:if test="${reportList.field != 'CATE_NAME'}">
		    		<b>${reportList.category}</b>
		</c:if>
		<c:if test="${reportList.field == 'CATE_NAME'}">
		    		${reportList.category}
		</c:if>
	</display:column>
	<display:column media="html" titleKey="report.form.table.header.totalInMonth" >
		
		<c:if test="${reportList.totalInMonth != '0'}">	
			<c:if test="${reportList.field != 'CATE_NAME'}">
			    		<b>${reportList.totalInMonth}</b>
			</c:if>
			<c:if test="${reportList.field == 'CATE_NAME'}">
			    		${reportList.totalInMonth}
			</c:if>
		</c:if>
	</display:column>
	
	<display:column media="html" titleKey="report.form.table.header.resolvedInMonth" >
		<c:if test="${reportList.resolvedInMonth != '0'}">	
			<c:if test="${reportList.field != 'CATE_NAME'}">
			    		<b>${reportList.resolvedInMonth}</b>
			</c:if>
			<c:if test="${reportList.field == 'CATE_NAME'}">
			    		${reportList.resolvedInMonth}
			</c:if>
		</c:if>
	</display:column>
	<display:column media="html" titleKey="report.form.table.header.resolvedOnTime" >
		<c:if test="${reportList.resolvedOnTime != '0'}">	
			<c:if test="${reportList.field != 'CATE_NAME'}">
			    		<b>${reportList.resolvedOnTime}</b>
			</c:if>
			<c:if test="${reportList.field == 'CATE_NAME'}">
			    		${reportList.resolvedOnTime}
			</c:if>
		</c:if>
	</display:column>
	<display:column media="html" titleKey="report.form.table.header.totalOverTime" >
		<c:if test="${reportList.totalOverTime != '0'}">	
			<c:if test="${reportList.field != 'CATE_NAME'}">
			    		<b>${reportList.totalOverTime}</b>
			</c:if>
			<c:if test="${reportList.field == 'CATE_NAME'}">
			    		${reportList.totalOverTime}
			</c:if>
		</c:if>
	</display:column>
	<display:column media="html" titleKey="report.form.table.header.overTimeLessThanFive" >
		<c:if test="${reportList.overTimeLessThanFive != '0'}">	
			<c:if test="${reportList.field != 'CATE_NAME'}">
			    		<b>${reportList.overTimeLessThanFive}</b>
			</c:if>
			<c:if test="${reportList.field == 'CATE_NAME'}">
			    		${reportList.overTimeLessThanFive}
			</c:if>
		</c:if>
	</display:column>
	<display:column media="html" titleKey="report.form.table.header.overTimeBetweenFiveAndTen" >
		<c:if test="${reportList.overTimeBetweenFiveAndTen != '0'}">	
			<c:if test="${reportList.field != 'CATE_NAME'}">
			    		<b>${reportList.overTimeBetweenFiveAndTen}</b>
			</c:if>
			<c:if test="${reportList.field == 'CATE_NAME'}">
			    		${reportList.overTimeBetweenFiveAndTen}
			</c:if>
		</c:if>
	</display:column>
	<display:column media="html" titleKey="report.form.table.header.overTimeBetweenTenAndTwenty" >
		<c:if test="${reportList.overTimeBetweenTenAndTwenty != '0'}">	
			<c:if test="${reportList.field != 'CATE_NAME'}">
			    		<b>${reportList.overTimeBetweenTenAndTwenty}</b>
			</c:if>
			<c:if test="${reportList.field == 'CATE_NAME'}">
			    		${reportList.overTimeBetweenTenAndTwenty}
			</c:if>
		</c:if>
	</display:column>
	<display:column media="html" titleKey="report.form.table.header.overTimeMoreThanTwenty" >
		<c:if test="${reportList.overTimeMoreThanTwenty != '0'}">	
			<c:if test="${reportList.field != 'CATE_NAME'}">
			    		<b>${reportList.overTimeMoreThanTwenty}</b>
			</c:if>
			<c:if test="${reportList.field == 'CATE_NAME'}">
			    		${reportList.overTimeMoreThanTwenty}
			</c:if>
		</c:if>
	</display:column>
	<display:column media="html" titleKey="report.form.table.header.totalNotApproved" >
		<c:if test="${reportList.totalNotApproved != '0'}">	
			<c:if test="${reportList.field != 'CATE_NAME'}">
			    		<b>${reportList.totalNotApproved}</b>
			</c:if>
			<c:if test="${reportList.field == 'CATE_NAME'}">
			    		${reportList.totalNotApproved}
			</c:if>
		</c:if>
	</display:column>
	<display:column media="html" titleKey="report.form.table.header.notApprovedBeforeDeadline" >
		<c:if test="${reportList.notApprovedBeforeDeadline != '0'}">	
			<c:if test="${reportList.field != 'CATE_NAME'}">
			    		<b>${reportList.notApprovedBeforeDeadline}</b>
			</c:if>
			<c:if test="${reportList.field == 'CATE_NAME'}">
			    		${reportList.notApprovedBeforeDeadline}
			</c:if>
		</c:if>
	</display:column>
	<display:column media="html" titleKey="report.form.table.header.notApprovedOverdue" >
		<c:if test="${reportList.notApprovedOverdue != '0'}">	
			<c:if test="${reportList.field != 'CATE_NAME'}">
			    		<b>${reportList.notApprovedOverdue}</b>
			</c:if>
			<c:if test="${reportList.field == 'CATE_NAME'}">
			    		${reportList.notApprovedOverdue}
			</c:if>
		</c:if>
	</display:column>
	
</display:table>

<c:if test="${fn:length(reports) gt 0}">
	<s:url action="exportDocFile!exportSynthesisReport.html"
		var="exportVoucherURL"></s:url>
	<s:a href="%{exportVoucherURL}" >
		<img src="${ctx}/images/export_word.png">
	</s:a>
</c:if>
<script type="text/javascript">

$(document).ready(function (){
		var currentTime = new Date();
		var month = currentTime.getMonth() + 1;
		var day = currentTime.getDate();
		if(month < 10) month = "0" + month;
		if(day < 10) day = "0" + day;
		var year = currentTime.getFullYear();
		
		var today = day + "/" + month + "/" + year;
		
		if($("#fromDate").val()=="")
	  		$("#fromDate").val(today);
		
		if($("#toDate").val()=="")
	  		$("#toDate").val(today);
	});
                                          
                                          
                                          
      var cal = Calendar.setup({
          onSelect: function(cal) { cal.hide();},
      });
      cal.manageFields("fromDate","fromDate","%d/%m/%Y");
      cal.manageFields("toDate","toDate","%d/%m/%Y");

</script>